﻿@{
    ViewBag.Title = "模型字段";
}
@section header{

}
<form id="form1">
    <div class="form-layout">
        <input type="hidden" id="ID" name="ID" value="" />
        <input type="hidden" id="DivModelID" name="DivModelID" value="" />
        <table class="form">
            <tr>
                <th class="formTitle">中文名称</th>
                <td class="formValue">
                    <input id="Name" name="Name" type="text" class="form-control " onblur="tickycms_pinyin()" autocomplete="off" />
                </td>
            </tr>

            <tr>
                <th class="formTitle">字段英文</th>
                <td class="formValue">
                    <input id="Field" name="Field" type="text" class="form-control " autocomplete="off" />
                </td>
            </tr>

            <tr>
                <th class="formTitle">字段类型</th>
                <td class="formValue">
                    <select id="FieldType" name="FieldType" class="form-control ">
                        <option value='0'>请选择字段类型</option>
                        <option value="input">单行文本</option>
                        <option value="textarea">多行文本</option>
                        <option value="number">整数类型</option>
                        <option value="datetime">时间类型</option>
                        <option value="image">图片上传</option>
                        <option value="images">多图片上传</option>
                        <option value="attachment">附件上传</option>
                        <option value="select">option下拉框</option>
                        <option value="radio">radio选项卡</option>
                        <option value="checkbox">checkbox多选框</option>
                        <option value="editor">编辑器</option>
                    </select>
                </td>
            </tr>

            <tr>
                <th class="formTitle">默认值</th>
                <td class="formValue">
                    <input id="DefaultValue" name="DefaultValue" type="text" class="form-control " autocomplete="off" />
                </td>
            </tr>
        </table>
    </div>
</form>

@section scripts{
    <script src="~/Content/js/pinyin/pinyin.js"></script>
    <script>
        var baseUrl = "/Divmodelfield/";
        var keyValue = $.request("keyValue");
        $(function () {
            initControl();
            if (!!keyValue) {
                $.ajax({
                    url: baseUrl + "GetFormJson",
                    data: { keyValue: keyValue },
                    dataType: "json",
                    async: false,
                    success: function (data) {
                        $("#form1").formSerialize(data);
                    }
                });
            }
        });
        function initControl() {

        }
        function submitForm() {
            if (!$('#form1').formValid()) {
                return false;
            }
            $.submitForm({
                url: baseUrl + "SubmitForm?keyValue=" + keyValue,
                param: $("#form1").formSerialize(),
                success: function () {
                    $.currentWindow().$("#gridList").resetSelection();
                    $.currentWindow().$("#gridList").trigger("reloadGrid");
                }
            })
        }
        function tickycms_pinyin() {
            var pinyin = codefans_net_CC2PY($("input[name='Name']").val());
            $("input[name='Field']").val(pinyin.toLowerCase());
        }
    </script>
}